GBML manual / Rooms

region_previous

The region the player was in before the last change of region, as a region word like rg_forest. It stays the same until the next change. -1 before the player has changed region once.

Syntax

region_previous() -> int

Returns

int

Description

The region the player was in before the last change of region, as a region word like rg_forest (see region_current). It stays the same until the next change, so you can ask it any time, not only in the frame of the change. It is -1 until the player has changed region once.

Inside a Region Entered or Region Exited event it says which region was left.

In a long room cut into regions it is the region the object the camera follows left when it crossed a border.

Example

if (region_entered() && region_previous() == rg_forest) {
    log_write("Came out of the forest");
}

Writes a line when the player arrives in a region from the forest.

See also: region_exitedregion_currentregion_enteredWhat a region does in the game